<template>
  <div id="app-container" style="padding:30px;">
    <el-form label-width="130px">
      <el-form-item label="版权名称">
        <el-select v-model="batch.serial" clearable placeholder="请选择">
          <el-option :value="1" label="连载中"/>
        </el-select>
      </el-form-item>
      <el-form-item label="批次名称">
        <el-col :span="5">
          <el-input v-model="batch.name"/>
        </el-col>
      </el-form-item>
      <el-form-item label="分成比例">
        <el-col :span="5">
          <el-input v-model="batch.proportion"/>
        </el-col>
      </el-form-item>
      <!-- TODO 版权 -->
      <!-- TODO 批次 -->
      <!-- TODO 书单 -->
      <el-form-item label="授权开始时间">
        <el-date-picker
          v-model="batch.startTime"
          type="datetime"
          placeholder="选择开始时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-form-item label="授权结束时间">
        <el-date-picker
          v-model="batch.endTime"
          type="datetime"
          placeholder="选择结束时间"
          value-format="yyyy-MM-dd HH:mm:ss"
          default-time="00:00:00"
        />
      </el-form-item>
      <el-form-item>
        <el-button :disabled="saveBtnDisabled" type="primary" @click="save()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import batch from '@/api/copyrightin/batch.js'
export default {
  data() {
    return {
      batch: {},
      saveBtnDisabled: false // 点击禁用这个按钮，false 禁用 true禁用
    }
  },
  methods: {
    save() {
      // 禁用按钮
      this.saveBtnDisabled = true
      // 调用add方法
      batch.add(this.batch)
        .then(response => {
          // 消息提示
          this.$message({
            type: 'success',
            message: '保存成功'
          })
          // 返回list列表页
          this.$router.push('/bms/copyright/list')
        })
    }
  }
}
</script>

